package com.eric.similarity;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import com.eric.similarity.cluster.MapClusterer;
import com.eric.similarity.pipe.FilePipe;
import com.eric.similarity.pipe.MongoPipe;
import com.eric.similarity.pipe.Pipe;

public class Main {

	public static void main(String[] args) throws IOException {
		Config.init();

		CosineSimilarity<String,Double> cs = new CosineSimilarity<String,Double>();
		
		Pipe<String> pipe = new MongoPipe<String>(Config.MONGO_HOST,Config.MONGO_DB,Config.MONGO_COLLECTION);

		cs.setPipe(pipe);
		cs.run();
		
		Pipe<String> filepipe = new FilePipe<String>();
		filepipe.write(cs.SimMap);
		
//		MapClusterer<String,String> cluster = new MapClusterer<String,String>();
//		System.out.println(pipe.getMap());
//		System.out.println(cs.getSim());
//		System.out.println(cluster.Cluster(cs.getSimMap()));

	}
	
	public static class Config {
		
		public static String MONGO_HOST;
		public static String MONGO_DB;
		public static String MONGO_COLLECTION;
		public static String DOC_NAME;
		public static String DOC_CONTENT;
		
		public static String PATH;
		public static String OUTPUT_PATH;
		
		public static String PIPE;
		
		public static void init () {
			Properties p = new Properties();
			try {
				p.load(new FileInputStream(new File("./Config")));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			MONGO_HOST = p.getProperty("MONGO_HOST");
			MONGO_DB = p.getProperty("MONGO_DB");
			MONGO_COLLECTION = p.getProperty("MONGO_COLLECTION");
			
			PATH = p.getProperty("PATH");
			OUTPUT_PATH = p.getProperty("OUTPUT_PATH");
			
			DOC_NAME = p.getProperty("DOC_NAME");
			DOC_CONTENT = p.getProperty("DOC_CONTENT");
		}
	}
}
